package com.slcf.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.slcf.dao.CrQuestionnaireMapper;
import com.slcf.service.CrQuestionnaireService;

@Service
public class CrQuestionnaireServiceImpl implements CrQuestionnaireService {

	@Autowired
	private CrQuestionnaireMapper crQuestionnaireMapper;
	
	@Override
	public void questionnaire(String nickName, String answer) {
		answer = conversionAnswer(answer);
		crQuestionnaireMapper.saveCrQuestionnaire(nickName, answer);
	}

	/**
	 * 答案转换，答案索引转换成对应字母
	 * @param answerIndex
	 * @return
	 */
	private String conversionAnswer(String answerIndex) {
		String ret = "ERROR";
		switch (answerIndex) {
			case "0":
				ret = "A";
				break;
			case "1":
				ret = "B";
				break;
			case "2":
				ret = "C";
				break;
			case "3":
				ret = "D";
				break;
			default:
				break;
		}
		return ret;
	}
}
